{include file="public/head"/}
</script>
<div id="main">
<div class="container-fluid">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="alert alert-dismissable alert-info">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
				<p></p>
            </div>
        </div>
    </div>
   
    
    <div class="ntDesktop">
    	<div class="ntDesktop-head">产品价格</div>
    	<input type="hidden" name="" id="album_id" value="{$album_id|default=''}">
    	<input type="hidden" name="" id="viewType" value="{$viewType|default=''}">
		<input type="hidden" id="delmodel" value="">
        <div class="row">
			<div class="col-md-4">
				<ul class="nav nav-tabs">
					<li :class="{'active':tabType=='PriceClass'}">
						<a href="#price_type" data-toggle="tab" @click="changeTab('PriceClass')">价格分类</a>
					</li>
					<li :class="{'active':tabType=='MerchDis'}">
						<a href="#price_discount" data-toggle="tab" @click="changeTab('MerchDis')">业务员折扣</a>
					</li>
					<li :class="{'active':tabType=='pricing'}">
						<a href="#price_setting" data-toggle="tab"  @click="changeTab('pricing')">定价</a>
					</li>
				</ul>
			</div>
			<div class="col-md-8 text-right" v-show="tabType=='PriceClass'">
				<a href="{:url('price/addpricetype')}" class="btn btn-primary" data-toggle="modal" data-target="#price_type_Modal" id="addPriceType" v-if="auth_ids.indexOf(306) != -1">
					<span class="fa fa-plus"></span> 添加价格分类
				</a>
			</div>
			<div class="col-md-8 text-right" v-show="tabType=='MerchDis'">
				<a href="{:url('price/positionprice')}" class="btn btn-primary" data-toggle="modal" data-target="#price_discount_Modal" v-if="auth_ids.indexOf(308) != -1">
					<span class="fa fa-plus"></span> 设置职务的折扣权限
				</a>
			</div>
			<div class="col-md-8 text-right" v-show="tabType=='pricing'">
				<div class="row">
					<div class="col-md-3 col-md-offset-3">
						<select name="" id="" class="form-control" id="proCateId" v-model="selproclass">
							<option value="0">选择产品分类</option>
							<option :value="item.id" v-for="(item,index) in proClass" v-html="item.content"></option>
						</select>
					</div>
					<div class="col-md-3">
						<input type="text" class="form-control" name="searchText" placeholder="搜索产品名称，角色ID，MODELO" v-model="selText">
					</div>
					<div class="col-md-1" style="float: right;margin-right: 1%">
						<button class="btn btn-primary" @click="priceAdd" v-if="auth_ids.indexOf(311) != -1"> 
							<span class="glyphicon glyphicon-floppy-disk"></span> 保存
						</button>
					</div>
					<div class="col-md-1" style="float: right;">
						<button class="btn btn-primary" @click="findFun"><span class="fa fa-search"></span> 查找</button>
					</div>
				</div>
			</div>
        </div>
        
		<div class="tab-content">
		
			<!--价格分类设置 -->
			<div :class="{'row':true, 'tab-pane':true, 'active':tabType=='PriceClass'}" id="price_type">
				<div class="col-md-12">
					<table class="table table-hover ntTable" style="table-layout:fixed;">
						<thead>
							<tr>
								<th>ID</th>
								<th>代号</th>
								<th>名称</th>
								<th>加成</th>
								<th>MOQ</th>
								<th>折扣</th>
								<th>固定</th>
								<th>排序</th>
								<th style="width: 300px;">授权职务</th style="width: 500px;">
								<th style="width: 300px;">授权部门</th>
								<th>编辑</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(item,index) in PriceClass">
								<td align="center">{{item.id}}</td>
								<td>{{item.code}}</td>
								<td>{{item.content}}</td>
								<td align="right">{{item.ratee}}<small class="unit">%</small></td>
								<td align="right">{{item.moqq}}<small class="unit">CTN</small></td>
								<td align="right">{{item.discountt}}<small class="unit">%</small></td>
								<td>{{item.fixx}}</td>
								<td align="right">{{item.drank}}</td>
								<td >{{item.position}}</td>
								<td>{{item.department}}</td>
								<td>{{item.nickname}}<br><small>{{item.time}}</small></td>
								<td align="right">
									<a :href="'/admin/price/pricetypeedit?id='+item.id" class="btn btn-primary" data-toggle="modal" data-target="#price_type_Modal" id="addPriceType" v-if="auth_ids.indexOf(307) != -1">
										编辑
									</a>
                          			<a href="javascript:;" class='btn btn-sm btn-default option-hide' @click="typeDeleteData(item.id,item.content)" v-if="item.fix==0 && auth_ids.indexOf(369) != -1">
                          				<span class="glyphicon glyphicon-eye-close"></span> {:strtoupper(lang('delete'))}</a>
								</td>
							</tr>
						</tbody>
					</table>
					<ul class="pagination" id="pagination" v-show="PriceClass.length!=0">
					</ul>
				</div>
			</div>
			
			<!-- 业务员 折扣设置 -->
			<div :class="{'row':true, 'tab-pane':true, 'active':tabType=='MerchDis'}" id="price_discount">
				<div class="col-md-12">
					<table class="table table-hover iTable ntTable">
						<thead>
							<tr>
								<th>ID</th>
								<th>职务</th>
								<th>范围</th>
								<th>次数</th>
								<th>金额</th>
								<th>编辑</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(item,index) in MerchDis">
								<td align="center">{{item.id}}</td>
								<td>{{item.langname}}</td>
								<td align="right">{{formatUnit(item.range,'%')}}%</td>
								<td align="right">{{item.qty}} <small class="unit">T</small></td>
								<td align="right">{{formatUnit(item.amount,'$')}} <small class="unit">BRL</small></td>
								<td>{{item.nickname}} <br><small>{{item.time}}</small></td>
								<td align="right">
									<a :href="'/admin/price/positionpriceedit?id='+item.id" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#price_discount_Modal" v-if="auth_ids.indexOf(309) != -1">编辑</a>
									<a @click='delDis(item.id)' class="btn btn-sm btn-default" v-if="auth_ids.indexOf(310) != -1">清除</a>
								</td>
							</tr>
						</tbody>
					</table>
					<ul class="pagination" id="MerchDis" v-show="MerchDis.length!=0">
					</ul>
				</div>
			</div>
			
			
			<!--价格设置 -->
			<div :class="{'row':true, 'tab-pane':true, 'active':tabType=='pricing'}" id="price_setting">
				<div class="col-md-12">
					<table class="table table-striped table-hover ntTable">
						<thead>
							<tr>
								<th class="sorting"> 产品 </th>
								<th class="sorting"> 箱规/库存</th>
								<th> CIF</th>
								<th>&nbsp; </th>
								<th v-for="(priitem,index) in pritype"><a href="#" data-toggle="tooltip" data-placement="top" :title="priitem.type_name">{{priitem.code}}</a></th>
								<th class="sorting" @click="sortEdit"> 编辑 </th>
								<th> 操作 </th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(item,index) in pricing">
								<td>
									<div class="pro">
										<div class="pro-icon">
											<a :href="'/admin/product/productDetail?request=detail&id='+item.pro_id" target="_blank">
												<img :src="item.img_url" border="0" width="48px" height="48px" alt="ICON">
											</a>
										</div>
										<div class="pro-name">
											<a :href="'/admin/product/productDetail?request=detail&id='+item.pro_id" target="_blank">
											<small>{{item.prochar_id > 0 ? item.prochar_id : item.pro_id}}{{item.brand_name ? ' / '+item.brand_name : ''}}{{item.model ? ' / '+item.model : ''}}</small> <br />
											{{item.pro_name}}
											</a>
										</div>
									</div>
								</td>
								<td align="right">
									{{formatUnit(item.prochar_qty,'UN')}} <small class="unit">PCS/CTN</small><br>
									{{item.ctn_size}} <small class="unit">CM</small><br>
									<hr class="hr-sm">
									{{formatUnit(item.reserve_pcs,'UN')}} <small class="unit">PCS</small><br>
									{{formatUnit(item.reserve_ctn,'UN')}} <small class="unit">CTN</small>
								</td>
								<td align="right">
									{{formatUnit(item.cif,'$')}} <small class="unit">BRL</small><br>
									{{formatUnit(item.fare,'$')}} <small class="unit">BRL</small><br>
									{{formatUnit(item.fare_cif,'%')}} <small class="unit">%</small>
								</td>
								<td align="right">
									<table class="text-right s-2">
										<tr style="line-height: 30px">
											<td>PRICE</td>
										</tr>
										<tr style="line-height: 16px">
											<td>PRO.%</td>
										</tr>
										<tr style="line-height: 30px">
											<td>MOQ</td>
										</tr>
										<tr style="line-height: 30px">
											<td>DIS.FIX</td>
										</tr>
									</table>
								</td>
								<td v-for="(priceitem,key) in item.price_value" style="width: 100px;">
									<input type="number" class="form-control input-sm text-right" placeholder="价格" style="width:8rem" :value="pricing[index].price_value[key].amount ? pricing[index].price_value[key].amount : ''" @change="putprice(index,key,'amount',$event)">
									<div class="label label-default text-right" style="display: block; width:100%">
										{{ 	pricing[index].price_value[key].amount-0 ? 
											getFloat((pricing[index].price_value[key].amount-item.cif)/pricing[index].price_value[key].amount*100,1) : 0}}%
									</div>
									<input type="number" class="form-control input-sm text-right" placeholder="数量" style="width:8rem" :value="pricing[index].price_value[key].moq ? pricing[index].price_value[key].moq : ''" @change="putprice(index,key,'moq',$event)">
									<input type="number" class="form-control input-sm text-right" placeholder="折扣限制" style="width:8rem" :value="pricing[index].price_value[key].discount_range ? pricing[index].price_value[key].discount_range : ''" @change="putprice(index,key,'discount_range',$event)"
									:disabled="pricing[index].price_value[key].priceTypeDiscount==0">
								</td>
								<td>
									{{item.nickname}} <br>
									<small>{{item.time}}</small>
								</td>
								<td align="right">
									<button class="btn btn-sm btn-primary" @click="autoFun(index)">自动</button>
									<button class="btn btn-sm btn-primary" @click="restore(index)">还原</button>
								</td>
							</tr>
							<tr v-show="pricing.length==0">
								<td colspan="13" class="no_date">
									<h3 style="text-align: center;">{:strtoupper(lang('no_data'))}</h3>
								</td>
							</tr>
						</tbody>
					</table>
					<ul class="pagination" id="pricing" v-show="pricing.length!=0">
					</ul>
				</div>
			</div>
		
		</div>
        
	</div>
</div>


<!--弹窗部分 开始-->


<!-- 价格分类 弹窗部分-->
<div class="modal fade ui-draggable" id="price_type_Modal" tabindex="-1" role="dialog" aria-labelledby="ntModalLabel1" aria-hidden="true" style="display: none;">
    <div class="modal-dialog modal-lg" style="width: 1200px; margin-top: 171px;">
        <div class="modal-content">	
        </div>
    </div>
</div>

<!-- 职务 价格折扣 弹窗部分-->

<div class="modal fade ui-draggable" id="price_discount_Modal" tabindex="-1" role="dialog" aria-labelledby="ntModalLabel2" aria-hidden="true" style="display: none;">
    <div class="modal-dialog modal-lg" style="width:1200px;margin-top: 171px; ">
        <div class="modal-content">
            
        </div>
    </div>
</div>

<!--弹窗部分 结束--></div>

<script src="/static/Admin/js/price.js"></script>
{include file="public/foot"/}